package com.woniuxy.oa.dao;

import com.woniuxy.oa.entity.Application;
import org.activiti.engine.task.Task;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @author Mr X
 */
public interface ApplicationDAO {
    /**
     * 增加申请
     *
     * @param application
     */
    @Insert("insert into oa_application values(#{id},#{emp.id},#{title},#{applicationTime},#{status},#{depIid},#{reason},#{leaveTime},#{returnTime})")
    public void add(Application application);

    /**
     * 通过员工ID查询历史申请记录
     *
     * @param empid
     */
    @Select("select * from oa_application where empid=#{empid}")
    @Results({
            @Result(column = "empid",property = "emp",one = @One(select = "com.woniuxy.oa.dao.EmpDAO.getEmpById",fetchType = FetchType.EAGER))
    })
    public List<Application> getById(String empid);

    /**
     * 修改申请状态
     *
     * @param status
     * @param id
     */
    @Update("update oa_applciation set status=#{status} where id=#{id}")
    public void updateStatus(String status, String id);

}
